function flatten(arr){
    let result = [];

    arr.forEach(item => {
        if(Array.isArray(item)){
            result = result.concat(flatten(item))
        }else{
            result = result.concat(item);
        }
    });

    return result;
}